package greedy;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description: 455. 分发饼干
 * User: Li_yizYa
 * Date: 2025/6/21
 * Time: 23:26
 */
public class Solution1 {
    public int findContentChildren(int[] g, int[] s) {
        if (g == null || g.length == 0 || s == null || s.length == 0) {
            return 0;
        }
        Arrays.sort(g);
        Arrays.sort(s);
        int ret = 0;
        int index = 0;
        for (int i = 0; i < s.length && index < g.length; i++) {
            if (s[i] >= g[index]) {
                ret++;
                index++;
            }
        }
        return ret;
    }
}
